var gatc = gatc || {};



gatc.insertHtml = function (dom, html, before) {
    
    var refChild = dom.lastElementChild;
    
    if (refChild)
    {
        var range = refChild.ownerDocument.createRange(),
        		fragment = range.createContextualFragment(html);
        
        if (before)
        {
        		range.setStartBefore(refChild = dom.firstChild);
        }
        else
        {
        		range.setStartAfter(refChild);
        }
        
        dom.insertBefore(fragment, refChild);
    }
    else
    {
    		dom.innerHTML = html;
    }
}
